package com.aruba.databingviewmodellivedata;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

/**
 * Created by aruba on 2021/9/11.
 */
public class IdolViewModel extends ViewModel {
    private Idol idol;

    public IdolViewModel() {

    }

    public void setIdolMutableLiveData(Idol idol) {
        if (idol == null) throw new NullPointerException("idol can not be null");

        this.idol = idol;
    }

    public MutableLiveData<String> getIdolName() {
        return idol.getName();
    }

    public MutableLiveData<Integer> getIdolStar() {
        return idol.getStar();
    }

    public MutableLiveData<String> getIdolImageUrl() {
        return idol.getImageUrl();
    }

    public MutableLiveData<Integer> getScore() {
        return idol.getScore();
    }

    public void addScore(int add) {
        idol.setScore(idol.getScore().getValue() + add);
    }
}
